<!DOCTYPE html>
<html>
<head>
  <title>欢迎登录</title>
  <link rel="stylesheet" type="text/css" href="/bootstrap/css/bootstrap.min.css">
  <script type="text/javascript" src="/js/jquery.min.js"></script>
  <script type="text/javascript" src="/js/md5.js"></script>
</head>
<body>
      <div class="container" style="margin-top:180px; ">

        <div class="col-md-6 col-md-offset-3">
            <div class="panel panel-primary">
                <div class="panel-heading">用户注册</div>
                <div class="panel-body">
                    <form id="formId" class="form-horizontal">
                        <div class="form-group">
                            <label for="uname" class="col-sm-2 control-label">用户名</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="username" id="usernameId" placeholder="请输入用户名">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="pwd" class="col-sm-2 control-label">密码</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="password" id="passwordId" placeholder="请输入密码">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <input value= "注册" onclick="register();" class="btn btn-danger">
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            </div>
    </div>
    <script type="text/javascript">
            function register() {
                var username = $("#usernameId").val();
                var password = $("#passwordId").val();

                //对密码加密
                //加盐  
                //一定要和后台，Android，iOS沟通好，盐要保持一致
                password = $.md5(password+"QWEzxc110");
                
                $.post({
                    url:'/account/register',
                    data : 'username='+username+'&password='+password,
                    //{status:1,message:"新增成功"}
                    //{status:0,message:"新增失败"}
                    success:function(obj){
                        if (obj.status==1) {
                            window.location.href="/account/login";
                        }else{
                            alert(obj.message);
                        }
                    },
                    error:function(){

                    }
                });
            }
    </script>
</body>
</html>
